<?php
require_once '../ptnhuan-web1/data/users.php';
?>
<form method="POST">
    username <input type="text" name="username">
    password <input type="password" name="password">
    <input type="submit" name="submit"  >  
</form>
<?php if (isset($_POST['submit'])) : ?>
    <?php
    $usersname = $_POST ['username'];
    $userspassword = $_POST ['password'];
    $isOK = FALSE;
    $index = -1;
    for ($i = 0; $i < count($users); $i++) {
        if ((strcmp($users[$i]['username'], $usersname) == 0 ) &&
                (strcmp($users[$i]['password'], $userspassword) == 0)) {
            $isOK = TRUE;
            $index = $i;
        }
    }
    if ($isOK) {
        header("Location: http://localhost/bichvan-web1/films_s.php?uid=" . $users[$index]['id']);
    } else {

        echo 'dang nhap khong thanh cong'; 
    }
    ?>
<?php endif; ?>
